%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Square well potential.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function QA_Movimento_Tunnelling
	Constant;
	figure(1);					clf;
	col='rb';

	m =87*uA;
	L =1e-6;
	V0=10*hP^2*pi^2/2/m/L^2;
	
	E =[0:.001:3]*V0;
	k1=sqrt(2*m* E    )/hP;
	k2=sqrt(2*m*(E-V0))/hP;
	for nn=1:length(E)
		Q =SMatrix(TMatrix(k2(nn),k1(nn),L)*TMatrix(k1(nn),k2(nn),0))*[0 ; 1];
		R(nn)=abs(Q(1))^2;		T(nn)=abs(Q(2))^2;
	end
	subplot(121),plot(R,E/V0,'b','LineWidth',1.4)
	set(gca,'xLim',[0 1],'yLim',[0 3],'FontSize',16,'LineWidth',1.4);%
	xlabel('\fontsize{16}{\itR} , {\itT}');
	ylabel('\fontsize{16}{\itE}');

	
	bet=[3 10];
	E_V=[0:.001:3];
	for bb=1:length(bet)
		kL =bet(bb)*sqrt(1-E_V);
		P =1./(1+(exp(kL)-exp(-kL)).^2 ./ (16*E_V.*(1-E_V) ));
		
		subplot(121),plot(P,E_V,col(bb),'LineWidth',1.4)
		set(gca,'xLim',[0 1],'yLim',[0 3],'FontSize',16,'LineWidth',1.4);%
		xlabel('\fontsize{16}{\itT}');
		ylabel('\fontsize{16}{\itE}');
		text(1,.5,['\fontsize{16}{\it\beta} = ',num2str(bet(bb))])
		hold on
	end
end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% T-Matrix

function T = TMatrix(k1,k2,L)
	T = 1/2*[exp(-i*k2*L) 0 ; 0 exp(i*k2*L) ] * [1+k1/k2 1-k1/k2 ; 1-k1/k2 1+k1/k2] * [exp(i*k1*L) 0 ; 0 exp(-i*k1*L) ];
end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% S-Matrix

function S = SMatrix(T)
	S = [-T(1,2)/T(2,2) T(1,1)-T(2,1)*T(1,2)/T(2,2) ; 1/T(2,2) -T(2,1)/T(2,2)];
end